#coding:utf8
'''
Created on 2017/2/20
21:33
@author: Moon
qq : 550302989
'''
import MySQLdb
import dbhost_conf
class MySqlConnection(object):

    def __init__(self):
        self.db_info = dbhost_conf.db_info

    def getMySqlDBConnection(self):
        try:
            self.conn=MySQLdb.connect(**self.db_info)
            self.cur=self.conn.cursor()
            return self.conn,self.cur
        except Exception,e:
            print 'Connection failed.'
            print e
            raise e

    def MySqlDBClose(self,conn,cur):
        cur.close()
        conn.close()

# if __name__ == "__main__":
#     mysqlconnection=MySqlConnection()
#     conn,cur=mysqlconnection.getMySqlDBConnection()
#     sql='select * from auth '
#     cur.execute(sql)
#
#     for i in cur.fetchall():
#
#         print i
#     mysqlconnection.MySqlDBClose(cur,conn)
